package com.example.java_chatroom1.mapper;

import com.example.java_chatroom1.model.MessageInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageInfoMapper {
    @Select("select message from message where sessionId=#{sessionId} order by postTime desc limit 1")
    String getLastMessageBySessionId(@Param("sessionId") Integer sessionId);

    @Select("select fromId,message from message where sessionId=#{sessionId} order by postTime desc limit 100")
    List<MessageInfo> getMessageInfosBySessionId(@Param("sessionId") Integer sessionId);
}
